package com.billdowney.qq.robot.timedTask;

import com.billdowney.qq.robot.util.MessageUtil;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.contact.Friend;
import net.mamoe.mirai.contact.Group;
import net.mamoe.mirai.message.data.Image;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import net.mamoe.mirai.utils.RemoteFile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

@EnableScheduling
@Component
public class testTask {
// 案例
//        @Scheduled(cron = "0/5 * * * * ?")
        private  void ss(){     //主动发送消息 可用
//            event.getBot().getId()  //从消息中获取当前机器人

          Bot b= Bot.getInstance(1011450786); //qq机器人
          Group group = b.getGroup(1080277228L);//目标群
          Friend friend = b.getFriend(2570889556L);//目标好友
          friend.sendMessage("好友消息回复");
          group.sendMessage("群信息发送");

        }
//        @Scheduled(cron = "0/5 * * * * ?")  //图片绝对路径可用
        void s1(){
                MessageChainBuilder builder = MessageUtil.createBuilder();

                Bot b= Bot.getInstance(1011450786); //qq机器人
                Group group = b.getGroup(1080277228L);  //目标群
//              //发送图片
//              group.sendMessage(MessageUtil.buildImageMessage(group.getBotAsMember(), new File("C:\\Users\\看竞争\\Pictures\\截图20220709111654.png")));
               RemoteFile remoteFile = group.getFilesRoot();

        }
//@Scheduled(cron = "0/5 * * * * ?")
        private  void tupian(){     //主动发送消息 可用
//            event.getBot().getId()  //从消息中获取当前机器人
        Bot b= Bot.getInstance(1011450786); //qq机器人
        Group group = b.getGroup(1080277228L);//目标群
        Friend friend = b.getFriend(2570889556L);//目标好友
//            Image.Builder image = Image.newBuilder("{F33E2582-9C66-2C43-E570-0E49901D866E}.png"); //图片key
            Image.Builder image = Image.newBuilder("{F03D2381-BD55-1C08-2592-195713946F6A}.jpg"); //图片key
            friend.sendMessage("好友消息回复");
        group.sendMessage(image.build());
//
    }



}
